home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Environments / Clean 1.2.4 / StdEnv / StdCharList.icl < prev    next >
Encoding:
Modula Implementation  |  1996-12-23  |  1022 b   |  38 lines  |  [TEXT/3PRM]

  1. implementation module StdCharList
  2.  
  3. // ****************************************************************************************
  4. //    Concurrent Clean Standard Library Module Version 1.1
  5. //    Copyright 1995 University of Nijmegen
  6. // ****************************************************************************************
  7.  
  8. import StdList, StdInt, StdChar
  9.  
  10. cjustify::!.Int ![.Char] -> .[Char]
  11. cjustify n s = spaces lmargin ++ s ++ spaces rmargin
  12. where
  13.     margin    = n - length s    
  14.     lmargin    = margin / 2    
  15.     rmargin    = margin - lmargin
  16.  
  17. ljustify::!.Int ![.Char] -> .[Char]
  18. ljustify n s = s ++ spaces (n - length s)
  19.  
  20. rjustify::!.Int ![.Char] -> [Char]
  21. rjustify n s = spaces (n - length s ) ++ s
  22.  
  23. flatlines::![[u:Char]] -> [u:Char]
  24. flatlines [a:x]    = a ++ ['\n'] ++ flatlines x
  25. flatlines []    = []
  26.  
  27. mklines::![Char] -> [[Char]]
  28. mklines []                     = []
  29. mklines [a:x] | a == '\n'    = [[]:mklines x]
  30.                             = [[a:hd result]:tl result]
  31. where 
  32.     result    =    case x of
  33.                      []    ->    [[]]
  34.                     n    ->    mklines x
  35.     
  36. spaces::!.Int -> .[Char]
  37. spaces n = repeatn n ' '
  38.